<?php
// +----------------------------------------------------------------------
// | ZanPianCMS
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.zanpiancms.com All rights reserved.
// +----------------------------------------------------------------------
// | BBS:  <http://www.zanpiancms.cc>
// +----------------------------------------------------------------------
namespace app\common\model;
use think\Model;
class Mcid extends Model{
	public function mcid_updata($id,$sid,$mcid=''){
		$rs = db('mcid');
		$data['mcid_id'] = $id;
		$data['mcid_sid'] = $sid;
		$rs->where($data)->delete();
		if(!empty($mcid) && !empty($id) && !empty($sid)){
		    if(is_array($mcid)){
		        $mcids = $mcid;
		    }else{
		        $mcids = explode(',',trim($mcid));	
		    }
		$mcids = array_filter(array_unique($mcids));	
		foreach($mcids as $key=>$val){
			if($val){
			    $datas[$key]['mcid_mid'] = $val;
			    $datas[$key]['mcid_sid'] = $sid;
			    $datas[$key]['mcid_id'] = $id;
			}
		}
		    if(isset($datas)){
		        $rs->insertAll($datas);   
		    }
		}
	}		


}